package BHeap;

public class BHNode<T extends Comparable<T>> {
	protected BHNode<T> parent;
	protected T data;
	protected int degree = 0;
	protected BHNode<T> child;
	protected BHNode<T> sibling;
	protected int priorit = 0;

	public BHNode(T data) {
		this.data = data;
	}

	public BHNode() {

	}

	protected BHNode<T> getParent() {
		return parent;
	}

	protected void setParent(BHNode<T> parent) {
		this.parent = parent;
	}

	protected int getDegree() {
		return degree;
	}

	protected void setDegree(int degree) {
		this.degree = degree;
	}

	protected BHNode<T> getChild() {
		return child;
	}

	protected void setChild(BHNode<T> child) {
		this.child = child;
	}

	protected BHNode<T> getSibling() {
		return sibling;
	}

	protected void setSibling(BHNode<T> sibling) {
		this.sibling = sibling;
	}

	@Override
	public String toString() {
		String resp = "NIL";
		if (!isEmpty()) {
			resp = data.toString();
		}
		return resp;
	}

	public boolean isEmpty() {
		return data == null;

	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof BHNode<?>) {
			if (this.data == null || ((BHNode<T>) obj).getData() == null)
				return this.data == ((BHNode<T>) obj).getData();
			return ((BHNode<T>) obj).getData().compareTo(this.data) == 0;
		}
		return false;
	}
}
